<html>
<head><meta charset="utf-8"><title>param ordering help · project-const-generics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/index.html">project-const-generics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html">param ordering help</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232017498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232017498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232017498">(Mar 26 2021 at 19:11)</a>:</h4>
<p><code>feature(const_generics)</code> allows types and consts to be arbitrarily ordered, while <code>min_const_generics</code> does not.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="p">,</span><span class="w"> </span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">T</span><span class="p">);</span><span class="w"></span>
</code></pre></div>
<p>results in:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">error</span>: <span class="nc">type</span><span class="w"> </span><span class="n">parameters</span><span class="w"> </span><span class="n">must</span><span class="w"> </span><span class="n">be</span><span class="w"> </span><span class="n">declared</span><span class="w"> </span><span class="n">prior</span><span class="w"> </span><span class="n">to</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">parameters</span><span class="w"></span>
<span class="w"> </span><span class="o">-</span>-&gt; <span class="nc">src</span><span class="o">/</span><span class="n">lib</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">3</span>:<span class="mi">28</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="mi">3</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="p">,</span><span class="w"> </span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">T</span><span class="p">);</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w">           </span><span class="o">-----------------^-</span><span class="w"> </span><span class="n">help</span>: <span class="nc">reorder</span><span class="w"> </span><span class="n">the</span><span class="w"> </span><span class="n">parameters</span>: <span class="nc">lifetimes</span><span class="p">,</span><span class="w"> </span><span class="n">then</span><span class="w"> </span><span class="n">types</span><span class="p">,</span><span class="w"> </span><span class="n">then</span><span class="w"> </span><span class="n">consts</span>: <span class="err">`</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="err">`</span><span class="w"></span>

<span class="n">error</span>: <span class="nc">aborting</span><span class="w"> </span><span class="n">due</span><span class="w"> </span><span class="n">to</span><span class="w"> </span><span class="n">previous</span><span class="w"> </span><span class="n">error</span><span class="w"></span>
</code></pre></div>
<p>it would be really nice to add a help message recommending <code>feature(const_generics)</code> if the user is on nightly.</p>
<p><span class="user-group-mention" data-user-group-id="3805">@project-const-generics</span> one of you interested in implementing this?</p>



<a name="232017529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232017529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232017529">(Mar 26 2021 at 19:11)</a>:</h4>
<p>Lmao</p>



<a name="232017542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232017542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232017542">(Mar 26 2021 at 19:11)</a>:</h4>
<p>i was just about to say "maybe I should PR an error message for this"</p>



<a name="232017722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232017722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232017722">(Mar 26 2021 at 19:13)</a>:</h4>
<p>is that a "I will PR an error message for this"? <span aria-label="sparkles" class="emoji emoji-2728" role="img" title="sparkles">:sparkles:</span></p>



<a name="232018114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232018114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232018114">(Mar 26 2021 at 19:16)</a>:</h4>
<p>aaaaaaaa maybe</p>



<a name="232018138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232018138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232018138">(Mar 26 2021 at 19:16)</a>:</h4>
<p>if I don't forget <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="232018465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232018465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232018465">(Mar 26 2021 at 19:19)</a>:</h4>
<p>it probably wouldn't be too hard to do right lol?</p>



<a name="232020125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232020125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232020125">(Mar 26 2021 at 19:33)</a>:</h4>
<p>shouldn't be too bad, yeah <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="232022782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232022782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232022782">(Mar 26 2021 at 19:53)</a>:</h4>
<p>ill try get to doing this soon then :P</p>



<a name="232042794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232042794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232042794">(Mar 26 2021 at 22:57)</a>:</h4>
<p>Can't we just stabilise relaxed parameter ordering instead?</p>



<a name="232042824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232042824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232042824">(Mar 26 2021 at 22:58)</a>:</h4>
<p>That seems to be what we want to do anyway.</p>



<a name="232042864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232042864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232042864">(Mar 26 2021 at 22:58)</a>:</h4>
<p>is that thing we can just do<span aria-label="tm" class="emoji emoji-2122" role="img" title="tm">:tm:</span></p>



<a name="232075981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232075981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232075981">(Mar 27 2021 at 08:55)</a>:</h4>
<p>would also work <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="232075997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232075997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232075997">(Mar 27 2021 at 08:55)</a>:</h4>
<p>are there still some bad error messages we have to deal with?</p>



<a name="232078910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232078910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232078910">(Mar 27 2021 at 09:55)</a>:</h4>
<p>(they’re less important, but I think the ones involving defaults may have issues sometimes, e.g. mixed with defaulted type parameters IIRC. last I checked the Ord impl used to order all generic params didn’t take defaults into account, causing misorderings in diagnostics, some re-checking and re-sorting, etc)</p>



<a name="232081101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081101">(Mar 27 2021 at 10:37)</a>:</h4>
<p>i think <span class="user-mention" data-user-id="326189">@jknodt</span> fixed the param ord issue, though we might sort parameters in some other way which is not yet fixed</p>



<a name="232081161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081161">(Mar 27 2021 at 10:38)</a>:</h4>
<p>tbh, it's probably enough to:</p>



<a name="232081177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081177">(Mar 27 2021 at 10:39)</a>:</h4>
<ul>
<li>look at the current tests and figure out if there is anything that's missing</li>
</ul>



<a name="232081229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081229">(Mar 27 2021 at 10:40)</a>:</h4>
<ul>
<li>search for <code>types, then consts</code> or just <code>types.*consts</code> and <code>consts.*types</code> to check if there is anything obvious that's missing</li>
</ul>



<a name="232081287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081287">(Mar 27 2021 at 10:41)</a>:</h4>
<ul>
<li>change the ordering to always be unordered, fix the help messages for type param defaults with const params</li>
</ul>



<a name="232081368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081368">(Mar 27 2021 at 10:42)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/feaac19f1710ebcfecc783d51f52a9b0d8e998f5/compiler/rustc_ast/src/ast.rs#L330-L354">https://github.com/rust-lang/rust/blob/feaac19f1710ebcfecc783d51f52a9b0d8e998f5/compiler/rustc_ast/src/ast.rs#L330-L354</a> defaulted types are not taken into account</p>



<a name="232081369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081369">(Mar 27 2021 at 10:42)</a>:</h4>
<ul>
<li>open PR with a short stabilization report, summarizing why we want params to be unordered</li>
</ul>



<a name="232081384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081384">(Mar 27 2021 at 10:43)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116113">lqd</span> <a href="#narrow/stream/260443-project-const-generics/topic/param.20ordering.20help/near/232081368">said</a>:</p>
<blockquote>
<p><a href="https://github.com/rust-lang/rust/blob/feaac19f1710ebcfecc783d51f52a9b0d8e998f5/compiler/rustc_ast/src/ast.rs#L330-L354">https://github.com/rust-lang/rust/blob/feaac19f1710ebcfecc783d51f52a9b0d8e998f5/compiler/rustc_ast/src/ast.rs#L330-L354</a> defaulted types are not taken into account</p>
</blockquote>
<p>hm, is that a problem though?</p>



<a name="232081435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081435">(Mar 27 2021 at 10:44)</a>:</h4>
<p>i think the check that param defaults come last is somewhere else</p>



<a name="232081437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081437">(Mar 27 2021 at 10:44)</a>:</h4>
<p>when you have both defaulted types and defaulted consts, yes</p>



<a name="232081450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081450">(Mar 27 2021 at 10:44)</a>:</h4>
<p>the Ord impl will misorder them in diagnostics some times</p>



<a name="232081455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081455">(Mar 27 2021 at 10:44)</a>:</h4>
<p>type and consts have the same ord if <code>unordered</code> is true</p>



<a name="232081458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081458">(Mar 27 2021 at 10:44)</a>:</h4>
<p>not sure why we would misorder them</p>



<a name="232081966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232081966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232081966">(Mar 27 2021 at 10:55)</a>:</h4>
<p>not when there are defaults involved, which must be trailing</p>



<a name="232082006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082006">(Mar 27 2021 at 10:56)</a>:</h4>
<p>can you think of an example where this is a problem?</p>



<a name="232082015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082015">(Mar 27 2021 at 10:56)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=8e6aca54224dcd9439f6a7f2c25604ef">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=8e6aca54224dcd9439f6a7f2c25604ef</a></p>



<a name="232082021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082021">(Mar 27 2021 at 10:56)</a>:</h4>
<p><code>&lt;'a, V = u8, const N: usize&gt;</code> in the suggestion is incorrect</p>



<a name="232082028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082028">(Mar 27 2021 at 10:56)</a>:</h4>
<p>because of the Ord issue I mentioned</p>



<a name="232082031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082031">(Mar 27 2021 at 10:56)</a>:</h4>
<p>yeah, but with <code>feature(const_generics)</code> this suggestion is fixed</p>



<a name="232082037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082037">(Mar 27 2021 at 10:57)</a>:</h4>
<p>and/or the code with checks the ordering and computes the suggestion ofc ^^</p>



<a name="232082052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082052">(Mar 27 2021 at 10:57)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=989353ea43ded486561c4f222f9446e7">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=989353ea43ded486561c4f222f9446e7</a></p>



<a name="232082124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082124">(Mar 27 2021 at 10:59)</a>:</h4>
<p>are you asking for examples of "bad error messages" that don't work today, or that wouldn't work when they are unordered ?</p>



<a name="232082138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082138">(Mar 27 2021 at 10:59)</a>:</h4>
<p>i am looking for bad error meesage we will have to deal with once we allow unordered consts/types</p>



<a name="232082188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082188">(Mar 27 2021 at 11:00)</a>:</h4>
<p>so anything we have to be careful about when we stabilize unordered ty/consts</p>



<a name="232082244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082244">(Mar 27 2021 at 11:00)</a>:</h4>
<p>so messages that won't work when they are unordered <strong>and</strong> aren't already fixed if <code>const_generics</code> is enabled</p>



<a name="232082259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082259">(Mar 27 2021 at 11:01)</a>:</h4>
<p>ok that wasn't clear to me, sorry</p>



<a name="232082286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082286">(Mar 27 2021 at 11:01)</a>:</h4>
<p>I thought you were asking about today's ordering, I don't remember from the top of my head if I saw bad ones with relaxed ordering but will check</p>



<a name="232082796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082796">(Mar 27 2021 at 11:11)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=a5a92de28b764c0210c8ab640767ee60">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=a5a92de28b764c0210c8ab640767ee60</a></p>



<a name="232082851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082851">(Mar 27 2021 at 11:12)</a>:</h4>
<p>that one is interesting <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> we already have the same issue with just type params <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="232082860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082860">(Mar 27 2021 at 11:12)</a>:</h4>
<p>this one has a few in the ordering, and missing defaults in the mesg</p>



<a name="232082885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082885">(Mar 27 2021 at 11:12)</a>:</h4>
<p>IIUC, yes, that is related to the <code>Ord</code> impl above</p>



<a name="232082892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082892">(Mar 27 2021 at 11:13)</a>:</h4>
<p>ah yeah, the missing defaults are something we have to fix <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="232082968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232082968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232082968">(Mar 27 2021 at 11:14)</a>:</h4>
<p>I had already fixed it in my branch IIRC</p>



<a name="232083008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232083008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232083008">(Mar 27 2021 at 11:15)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116113">lqd</span> <a href="#narrow/stream/260443-project-const-generics/topic/param.20ordering.20help/near/232082885">said</a>:</p>
<blockquote>
<p>IIUC, yes, that is related to the <code>Ord</code> impl above</p>
</blockquote>
<p>that's the same issue only for types: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=2e9948590557d5becd190b2ac7bbfcf3">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=2e9948590557d5becd190b2ac7bbfcf3</a></p>



<a name="232083028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232083028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232083028">(Mar 27 2021 at 11:15)</a>:</h4>
<p>i think it is fine to require two steps when just following the one error message here</p>



<a name="232083079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232083079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232083079">(Mar 27 2021 at 11:16)</a>:</h4>
<p>though of course it would be good to get this completely right and consider defaults here if it isn't too much work</p>



<a name="232083663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232083663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232083663">(Mar 27 2021 at 11:27)</a>:</h4>
<p>it was more scary to me changing the whole ordering than a question of how much work <span aria-label="scream" class="emoji emoji-1f631" role="img" title="scream">:scream:</span> I wasn't sure (and still am) whether just <a href="https://github.com/lqd/rust/blob/more_const_generics_defaults/compiler/rustc_ast/src/ast.rs#L310-L350">https://github.com/lqd/rust/blob/more_const_generics_defaults/compiler/rustc_ast/src/ast.rs#L310-L350</a> would have implications elsewhere</p>



<a name="232083731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232083731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232083731">(Mar 27 2021 at 11:28)</a>:</h4>
<p>but yeah some of that work improved diagnostics slightly <a href="https://github.com/lqd/rust/blob/more_const_generics_defaults/src/test/ui/const-generics/defaults/const-defaults-order.full.stderr">https://github.com/lqd/rust/blob/more_const_generics_defaults/src/test/ui/const-generics/defaults/const-defaults-order.full.stderr</a></p>



<a name="232083945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232083945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232083945">(Mar 27 2021 at 11:32)</a>:</h4>
<p><span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="232083947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232083947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232083947">(Mar 27 2021 at 11:32)</a>:</h4>
<p>but in truth I looked at this mostly so that <a href="https://github.com/lqd/rust/blob/more_const_generics_defaults/compiler/rustc_ast_passes/src/ast_validation.rs#L720-L852"><code>validate_generic_param_order</code></a> doesn't have to do all that work when the parameters are already correctly sorted</p>



<a name="232084179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232084179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232084179">(Mar 27 2021 at 11:36)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116113">lqd</span> <a href="#narrow/stream/260443-project-const-generics/topic/param.20ordering.20help/near/232083663">said</a>:</p>
<blockquote>
<p>it was more scary to me changing the whole ordering than a question of how much work <span aria-label="scream" class="emoji emoji-1f631" role="img" title="scream">:scream:</span> I wasn't sure (and still am) whether just <a href="https://github.com/lqd/rust/blob/more_const_generics_defaults/compiler/rustc_ast/src/ast.rs#L310-L350">https://github.com/lqd/rust/blob/more_const_generics_defaults/compiler/rustc_ast/src/ast.rs#L310-L350</a> would have implications elsewhere</p>
</blockquote>
<p>there's <a href="https://github.com/rust-lang/rust/issues/83556">https://github.com/rust-lang/rust/issues/83556</a> which is probably caused by us sorting params if they are incorrectly ordered</p>



<a name="232084508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232084508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232084508">(Mar 27 2021 at 11:43)</a>:</h4>
<p>if they're only sorted in diagnostics, we could fix that without much worry; I was mostly concerned about other unexpected consequences, say e.g. on the order of substs (though of course I'm not sure whether that would in fact change and whether defaults would need to be involved if that happened) if you all think this is safe enough, I can try to rebase that work on ordering and diagnostics, so at least CI gets a chance to see if that'd cause regressions</p>



<a name="232084566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232084566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232084566">(Mar 27 2021 at 11:44)</a>:</h4>
<blockquote>
<p>if they're only sorted in diagnostics,</p>
</blockquote>
<p>not completely sure, it probably makes sense to check where <code>ParamKindOrd</code> is used</p>



<a name="232084574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232084574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232084574">(Mar 27 2021 at 11:44)</a>:</h4>
<p>but yeah, opening a PR is probably good</p>



<a name="232084579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232084579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232084579">(Mar 27 2021 at 11:44)</a>:</h4>
<p>the efficiency gain on <code>validate_generic_param_order</code> was so small that I didn't feel the need to push this to completion</p>



<a name="232084928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232084928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232084928">(Mar 27 2021 at 11:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/260443-project-const-generics/topic/param.20ordering.20help/near/232084574">said</a>:</p>
<blockquote>
<p>but yeah, opening a PR is probably good</p>
</blockquote>
<p>will do</p>



<a name="232097121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232097121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232097121">(Mar 27 2021 at 15:23)</a>:</h4>
<blockquote>
<p>I was mostly concerned about other unexpected consequences, say e.g. on the order of substs</p>
</blockquote>
<p>I'm pretty sure all the (explicit) reliance on ordering was fixed a while back. I think the only way to know now is to write a number of tests for arbitrary parameter ordering to make sure nothing is going wrong.</p>



<a name="232105860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232105860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> jknodt <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232105860">(Mar 27 2021 at 17:42)</a>:</h4>
<p>just curious, is there anything like quickcheck in the compiler for permutation testing?</p>



<a name="232106724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232106724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232106724">(Mar 27 2021 at 17:56)</a>:</h4>
<p>i think not, i've seen some issue which were found by something like that. But i can't remember the name of that program rn</p>



<a name="232124771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232124771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232124771">(Mar 27 2021 at 23:06)</a>:</h4>
<p>heh, fixing the defaulted types' order makes <code>struct Foo&lt;'a, const N: usize, T = u32&gt;(&amp;'a (), T);</code> unexpectedly compile under <code>min_const_generics</code>. the incompatibility check seems to rely on the incorrect ordering (and does not emit a dedicated error or note for that case today, only the incorrect ordering one)</p>



<a name="232158589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232158589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232158589">(Mar 28 2021 at 10:41)</a>:</h4>
<p><span class="user-mention" data-user-id="116113">@lqd</span>: I think I'm misinterpreting what you're saying. The following emits an error on stable:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">struct</span> <span class="nc">Foo</span><span class="o">&lt;'</span><span class="na">a</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="p">,</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kt">u32</span><span class="o">&gt;</span><span class="p">(</span><span class="o">&amp;'</span><span class="na">a</span><span class="w"> </span><span class="p">(),</span><span class="w"> </span><span class="n">T</span><span class="p">);</span><span class="w"> </span><span class="c1">// error: type parameters must be declared prior to const parameters</span>
</code></pre></div>
<p>Is this not what you mean?</p>



<a name="232161804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232161804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232161804">(Mar 28 2021 at 11:46)</a>:</h4>
<p><span class="user-mention" data-user-id="121053">@varkor</span> it is what I mean indeed: that error is incorrect (but saves us here), T cannot be declared before N. That code is still erroneous under <code>min_const_generics</code> of course, but no errors or messages about the incompatibility between defaulted types and const generics are emitted. Fixing the <code>ParamKindOrd</code> <code>Ord</code> impl w.r.t defaulted types makes it that this already correct ordering does not trigger the error you mention; the missing <code>min_const_generics</code> incompatibility error here means that the code compiles (on my branch with the fix).</p>



<a name="232162067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232162067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232162067">(Mar 28 2021 at 11:52)</a>:</h4>
<p>the defaulted types + consts incompatibility note, emitted <a href="https://github.com/rust-lang/rust/blob/505ed7fb1b45236b312099b00be78175d67499a7/compiler/rustc_ast_passes/src/ast_validation.rs#L1153-L1180">here</a>, only happens as part of a misordered defaulted parameter's error, and if const generics defaults are not enabled (which is probably erroneous as well, no const generics defaults are involved here)</p>



<a name="232162108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232162108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232162108">(Mar 28 2021 at 11:54)</a>:</h4>
<p>but it's ok I'll take care of this at the same time :)</p>



<a name="232178291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232178291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232178291">(Mar 28 2021 at 16:48)</a>:</h4>
<p>It seems correct to me: the defaulted type parameter is still a type parameter. (Though I agree it's not a helpful error message!)</p>



<a name="232179368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232179368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232179368">(Mar 28 2021 at 17:06)</a>:</h4>
<p>sorry I'm not sure I understand what you mean :/ defaulted parameters cannot be declared prior to other non-defaulted parameters</p>



<a name="232179603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232179603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232179603">(Mar 28 2021 at 17:10)</a>:</h4>
<p>but it's ok, the better solution will be to relax the ordering as you've mentioned anyway</p>



<a name="232179624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232179624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232179624">(Mar 28 2021 at 17:10)</a>:</h4>
<p>(rather than a bunch of things I'm doing now)</p>



<a name="232187995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/param%20ordering%20help/near/232187995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/param.20ordering.20help.html#232187995">(Mar 28 2021 at 19:37)</a>:</h4>
<blockquote>
<p>sorry I'm not sure I understand what you mean :/ defaulted parameters cannot be declared prior to other non-defaulted parameters</p>
</blockquote>
<p>That's also true. The constraints are impossible to satisfy :P</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>